package com.example.tilas1.service.impl;

import com.example.tilas1.mapper.DeptMapper;
import com.example.tilas1.pojo.Dept;
import com.example.tilas1.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

@Service
public class DeptServiceimpl implements DeptService {
    @Autowired
    DeptMapper deptMapper;

    @Override
    public void insert(Dept dept) {

        if (ObjectUtils.isEmpty(dept.getName())){
            return;
        }
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insert(dept);
    }

    @Override
    public void delete(Integer id) {
        deptMapper.delete(id);
    }

    @Override
    public List<Dept> select() {
    return deptMapper.select();
    }
}
